<?php

namespace app\controller;

use think\facade\Db;
use think\Request;

class AList
{
    public function news(Request $request)
    {
        $list = (Db::name('news')->field('id,title,time,image')->order('time', 'desc')->paginate([
            'page' => $request->param('page'),
            'list_rows' => $request->param('limit'),
        ], true))->each(function ($item, $key) {
            $item['time'] = substr($item['time'], 0, 10);
            return $item;
        })->all();
        return json()->data(['code' => 200, 'data' =>  $list, 'msg' => '成功']);
    }
    public function notice(Request $request)
    {
        $list = (Db::name('notice')->order('time', 'desc')->paginate([
            'page' => $request->param('page'),
            'list_rows' => $request->param('limit'),
        ], true))->each(function ($item, $key) {
            $item['time'] = substr($item['time'], 0, 10);
            return $item;
        })->all();
        return json()->data(['code' => 200, 'data' =>  $list, 'msg' => '成功']);
    }
    public function beauty(Request $request)
    {
        $list = (Db::name('beauty')->order('time', 'desc')->paginate([
            'page' => $request->param('page'),
            'list_rows' => $request->param('limit'),
        ], true))->each(function ($item, $key) {
            $item['time'] = substr($item['time'], 0, 10);
            return $item;
        })->all();
        return json()->data(['code' => 200, 'data' =>  $list, 'msg' => '成功']);
    }
}
